from dotenv import dotenv_values
from flask import Flask
from flask_caching import Cache

cache = Cache()

config = dotenv_values('.flaskenv')



# MySql配置信息
REDIS_HOST = config.get('REDIS_HOST') or '124.221.213.179'
REDIS_PORT = config.get('REDIS_PORT') or 6379
CACHE_TYPE = config.get('CACHE_TYPE') or 'redis'
CACHE_REDIS_PASSWORD= 'lsz&&ZSR666'
# 生产环节
pro_redis_config = {
    'CACHE_TYPE': CACHE_TYPE,
    'CACHE_REDIS_HOST': REDIS_HOST,
    'CACHE_REDIS_PORT': 6379,
    'CACHE_REDIS_PASSWORD': CACHE_REDIS_PASSWORD

}

# 开发环境
dev_redis_config = {
    'CACHE_TYPE': CACHE_TYPE,
    'CACHE_REDIS_HOST': '127.0.0.1',
    'CACHE_REDIS_PORT': 6379,
    'CACHE_REDIS_PASSWORD': '',
    'decode_responses':True
}


def init_cache(app: Flask):
    # cache.init_app(app=app, config=dev_redis_config,)  # ,config=config['']
    cache.init_app(app=app, config=pro_redis_config)

if __name__ == '__main__':
    pass
